home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / python2.4 / test / test_pickle.pyc (.txt) < prev    next >
Python Compiled Bytecode  |  2005-10-18  |  3KB  |  87 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.4)
  3.  
  4. import pickle
  5. import unittest
  6. from cStringIO import StringIO
  7. from test import test_support
  8. from test.pickletester import AbstractPickleTests
  9. from test.pickletester import AbstractPickleModuleTests
  10. from test.pickletester import AbstractPersistentPicklerTests
  11.  
  12. class PickleTests(AbstractPickleTests, AbstractPickleModuleTests):
  13.     
  14.     def dumps(self, arg, proto = 0, fast = 0):
  15.         return pickle.dumps(arg, proto)
  16.  
  17.     
  18.     def loads(self, buf):
  19.         return pickle.loads(buf)
  20.  
  21.     module = pickle
  22.     error = KeyError
  23.  
  24.  
  25. class PicklerTests(AbstractPickleTests):
  26.     error = KeyError
  27.     
  28.     def dumps(self, arg, proto = 0, fast = 0):
  29.         f = StringIO()
  30.         p = pickle.Pickler(f, proto)
  31.         if fast:
  32.             p.fast = fast
  33.         
  34.         p.dump(arg)
  35.         f.seek(0)
  36.         return f.read()
  37.  
  38.     
  39.     def loads(self, buf):
  40.         f = StringIO(buf)
  41.         u = pickle.Unpickler(f)
  42.         return u.load()
  43.  
  44.  
  45.  
  46. class PersPicklerTests(AbstractPersistentPicklerTests):
  47.     
  48.     def dumps(self, arg, proto = 0, fast = 0):
  49.         
  50.         class PersPickler(pickle.Pickler):
  51.             
  52.             def persistent_id(subself, obj):
  53.                 return self.persistent_id(obj)
  54.  
  55.  
  56.         f = StringIO()
  57.         p = PersPickler(f, proto)
  58.         if fast:
  59.             p.fast = fast
  60.         
  61.         p.dump(arg)
  62.         f.seek(0)
  63.         return f.read()
  64.  
  65.     
  66.     def loads(self, buf):
  67.         
  68.         class PersUnpickler(pickle.Unpickler):
  69.             
  70.             def persistent_load(subself, obj):
  71.                 return self.persistent_load(obj)
  72.  
  73.  
  74.         f = StringIO(buf)
  75.         u = PersUnpickler(f)
  76.         return u.load()
  77.  
  78.  
  79.  
  80. def test_main():
  81.     test_support.run_unittest(PickleTests, PicklerTests, PersPicklerTests)
  82.     test_support.run_doctest(pickle)
  83.  
  84. if __name__ == '__main__':
  85.     test_main()
  86.  
  87.